home *** CD-ROM | disk | FTP | other *** search
/ Shareworld 8 / Shareworld 8 (Disk 2 of 2).adf / Programs / MachineCodeHelloWorld / HelloWorld.ASM < prev    next >
Encoding:
Assembly Source File  |  1978-02-11  |  5.6 KB  |  222 lines

  1. ;  -------------------------------------------------------------------
  2. ;  A Hello World program based on the Blitz Basic original 
  3. ;  by Carl Read. Assembler version by Matthew Goode 18/1/97
  4. ;
  5. ;  Feel free to use any part of this program in your own, and, although
  6. ;  you can claim it as your own, please be considerate and give credit 
  7. ;  where credit is due.
  8. ;  -------------------------------------------------------------------
  9.  
  10. ;  -------------------------------------------------------------------
  11. ;  ------------------- Environment Design ----------------------------
  12.  
  13. UseIntuitionLib    =    1
  14. UseGraphicsLib    =    1
  15.  
  16. ;  -------------------------------------------------------------------
  17. ;  ------------------ Included (External) Constants ------------------
  18.  
  19.     IncDir "work:Assem/Include/"
  20.  
  21. ;  ----- Executive Stuff ------
  22.     Include "exec/Exec_lib.i"
  23.     Include "exec/ExecBase.i"
  24.  
  25. ;  ----- Graphics Stuff ------
  26.     Include "Graphics/Graphics_lib.i"
  27.  
  28. ;  ----- Intuition Stuff ------
  29.     Include "Intuition/Intuition_lib.i"
  30.     Include "Intuition/Intuition.i"
  31.  
  32. ;  ----- WorkBench Stuff ------
  33.     Include "WorkBench/WorkBench.i"
  34.  
  35. ;  ----- Other Stuff ------
  36.     Include "Libraries/DosExtens.i"
  37.  
  38. ;  ----- My Stuff ------
  39.     IncDir "work:Assem/MyIncludes/"
  40.     Include "StandardMacros.i"
  41.     Include "SimpleWorkbenchStart.i"    
  42.     Include "OpIntuitionMacros.i"
  43.  
  44. ;  -------------------------------------------------------------------
  45. ;  ------------------- Internal Constants ----------------------------
  46.  
  47. screenWidth    =    640
  48. screenHeight    =    256
  49. mainWindowWidth    =    300
  50. mainWindowHeight    =    200
  51. mainWindowXPos    =    (screenWidth-mainWindowWidth)/2
  52. mainWindowYPos    =    (screenHeight-mainWindowHeight)/2
  53. mainWindowDetailPen    =    2
  54. mainWindowBlockPen    =    1
  55. mainWindowIDCMP    =    CLOSEWINDOW
  56. mainWindowFlags    =    WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+SMART_REFRESH+RMBTRAP+GIMMEZEROZERO
  57. mainWindowMinWidth    =    40    
  58. mainWindowMinHeight    =    40
  59. mainWindowMaxWidth    =    -1
  60. mainWindowMaxHeight    =    -1
  61.  
  62. mainWindowType    =    WBENCHSCREEN
  63.  
  64. textCol    =    1
  65. backCol    =    0
  66.  
  67. ;  -------------------------------------------------------------------
  68. ;  --------------------- Internal Macros -----------------------------
  69.  
  70. ;  -------------------------------------------------------------------
  71. ;  -------------------- Main Program ---------------------------------
  72.  
  73. TheBegining
  74.     StartHerUp
  75. OpenWindows
  76.     Bsr OpenMainWindow
  77.     beq WindowFailure
  78.  
  79.     Bsr MainSetup
  80.     Bsr MainLoop
  81.  
  82. WindowFailure
  83.     Bsr CloseMainWindow
  84.  
  85.     TidyUp    ;No need for a RTS
  86.  
  87.     
  88. ;  -------------------------------------------------------------------
  89.  
  90. MainSetup
  91.     Move.w #0,scrollCount
  92.     rts
  93.  
  94. MainLoop
  95. .ll1
  96.     ;CALLGRAF WaitTOF    ;Use this line for a smoother demo.
  97.  
  98.     move.l mainWindowHandle,a2
  99.     move.l mainWindowRast,a3
  100.  
  101.     moveq #0,d2        ;Here we get the dimensions of the window
  102.     moveq #0,d3        ;Note that since this is a GIMMEZEROZERO
  103.                 ;Window we do not have to worry about the
  104.                 ;borders. Usually it is better to use
  105.                 ;Normal Windows as they can be faster.
  106.     move.w wd_GZZWidth(a2),d4
  107.     move.w wd_GZZHeight(a2),d5
  108.     Sub.w #1,d4    ;Adjust for 'Of by One Errors
  109.     Sub.w #1,d5
  110.     
  111.     tst.w scrollCount    ;Is it time to Reprint?
  112.     bne .noReprintMessage
  113.     GetFontHeight a3,d0    ;Get verticle displacement
  114.     move.w d0,scrollCount
  115.     
  116.     move.w d5,d1
  117.     sub.w d0,d1    ;Get YPos of text
  118.  
  119.     move.w d2,d0    ;Get XPos of text
  120.  
  121.     lea iTextStruct,a1
  122.     lea message,a0
  123.     move.l a0,textToPrint_p    
  124.     lea (a3),a0    ;Get RastPort
  125.     CALLINT PrintIText
  126.  
  127. .noReprintMessage
  128.     moveq #0,d0    ;No horizontal scroll
  129.     moveq #1,d1
  130.     lea (a3),a1    ;Get RastPort for scroll
  131.     CALLGRAF ScrollRaster    
  132.  
  133.     sub.w #1,scrollCount
  134.  
  135.  
  136.     move.l mainWindowHandle,a3
  137.     Bsr GetMessageFromWindow
  138.     Beq .ll1
  139.     Cmp.l #CLOSEWINDOW,d1    ;Not really necessary as this is the only
  140.                 ;message possible
  141.     bne .ll1
  142.     rts
  143.  
  144. ;  -------------------------------------------------------------------
  145.  
  146. GetMessageFromWindow    
  147.     ;Waits for a message from the window in a3 and then procedes to 
  148.     ;get message.
  149.     ;On Exiting: a0 - holds pointer to message
  150.     ;            d1 - holds message class
  151.     ;          z flag set if message Found    
  152.     move.l wd_UserPort(a3),a0
  153.     CALLEXEC GetMsg
  154.     move.l d0,a0
  155.     move.l im_Class(a0),d1        
  156.     Tst.l d0
  157.     rts
  158.  
  159. ;  -------------------------------------------------------------------
  160.  
  161. OpenMainWindow
  162.     ;Opens the main window 
  163.     ; D0 holds handle on exit (will be zero if failure)
  164.     ; No need to test as Status Flags will already be set
  165.     Lea newMainWindow,a0
  166.     CALLINT OpenWindow
  167.     Move.l d0,a0
  168.     Move.l wd_RPort(a0),mainWindowRast
  169.     Move.l d0,mainWindowHandle
  170.     rts
  171.  
  172. CloseMainWindow
  173.     ;Closes the Window if it was opened
  174.     Move.l mainWindowHandle,d0
  175.     Beq .noWindow
  176.     Move.l d0,a0
  177.     CALLINT CloseWindow
  178.     Clr.l mainWindowHandle
  179. .noWindow    
  180.     rts
  181.  
  182.  
  183. ;  -------------------------------------------------------------------
  184. ;  ---------------- Physical Constants -------------------------------
  185.  
  186.     Include "LibraryNames.i"
  187.     even    
  188.  
  189. newMainWindow
  190.     dc.w mainWindowXPos,mainWindowYPos,mainWindowWidth,mainWindowHeight
  191.     dc.b mainWindowDetailPen,mainWindowBlockPen
  192.     dc.l mainWindowIDCMP,mainWindowFlags
  193.     dc.l 0    ;Pointer to first Gadget
  194.     dc.l 0,mainWindowTitle,0,0    ;CheckMark,title,screen,bitmap
  195.     dc.w mainWindowMinWidth,mainWindowMinWidth,mainWindowMaxWidth,mainWindowMaxHeight
  196.     dc.w 1    ;mainWindowType
  197.  
  198. mainWindowTitle
  199.     dc.b "<- Click to exit",0
  200.     Even
  201.  
  202. message                             
  203.     dc.b " Hello World!  I'm an ASSEMBLER program!!!!!!!.",0 
  204.  
  205. ;  -------------------------------------------------------------------
  206. ;  ---------------- Variables ----------------------------------------
  207.  
  208. iTextStruct    dc.b textCol,backCol,RP_JAM2,0
  209.         dc.w 0,0
  210.         dc.l 0
  211. textToPrint_p    dc.l 0,0
  212.  
  213.     Include "StandardVaribles.i"
  214.  
  215. mainWindowHandle    ds.l 1
  216. mainWindowRast        ds.l 1
  217.  
  218. scrollCount    ds.w 1    ;The scroller counter
  219.  
  220. ;  -------------------------------------------------------------------
  221.  
  222.